//
//  SQLiteManager.swift
//  Fitness
//
//  Created by Ethan on 2022/10/8.
//

import Foundation

class SQLiteManager: NSObject {
    private static let manger: SQLiteManager = SQLiteManager()
    class func getInstance() -> SQLiteManager {
        return manger;
    }
    
    private let dbName = "table_basic.db"
    lazy var dbURL: URL = {
        let fileURL = try! FileManager.default
            .url(for: .applicationSupportDirectory, in: .userDomainMask,
                 appropriateFor: nil, create: true)
            .appendingPathComponent(dbName)
        print("--------> Database URL: ",fileURL)
        return fileURL
    }()
    lazy var db: FMDatabase = {
        let database = FMDatabase(url: dbURL)
        return database
    }()
    
    lazy var dbQueue: FMDatabaseQueue? = {
        let databaseQueue = FMDatabaseQueue(url: dbURL)
        return databaseQueue
        
    }()
}
